import {
  DefaultFooter,
  MenuDataItem,
  getMenuData,
  getPageTitle
} from "@ant-design/pro-layout";
import { Helmet } from "react-helmet";
import Link from "umi/link";
import React, { useEffect } from "react";
import { connect } from "dva";
import SelectLang from "@/components/SelectLang";
import { ConnectProps, ConnectState } from "@/models/connect";
import logo from "../assets/logo.svg";
import styles from "./UserLayout.less";

export interface UserLayoutProps extends ConnectProps {
  breadcrumbNameMap: {
    [path: string]: MenuDataItem;
  };
}

const UserLayout: React.FC<UserLayoutProps> = props => {
  const {
    route = {
      routes: []
    }
  } = props;
  const { routes = [] } = route;
  const {
    children,
    location = {
      pathname: ""
    }
  } = props;
  useEffect(() => {
    console.log(props);
    let search = window.location.search.replace("?qrresult=", "");
    if (search) {
      window.location.href = "https://skp.dingplayer.com//#/dj/" + search;
    }
  }, []);
  const { breadcrumb } = getMenuData(routes);
  const title = getPageTitle({
    pathname: location.pathname,
    breadcrumb,
    ...props
  });
  return (
    <>
      <Helmet>
        <title>{title}</title>
        <meta name="description" content={title} />
      </Helmet>

      <div className={styles.container}>
        <div className={styles.content}>{children}</div>
        {/* <DefaultFooter /> */}
      </div>
    </>
  );
};

export default connect(({ settings }: ConnectState) => ({ ...settings }))(
  UserLayout
);
